package com.saas.tenant.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.saas.tenant.entity.MyData;
import com.saas.tenant.service.MyDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @auther Jiang Tian
 * @date 2025/2/28
 * @apiNote
 **/
@RestController
@RequestMapping("/myData")
public class MyDataController {

    @Autowired
    private MyDataService myDataService;

    // 查询所有用户
    @GetMapping("/getAllData")
    public List<MyData> getAllData() {
        return myDataService.list();
    }

    // 根据 ID 查询用户
    @GetMapping("/{id}")
    public MyData getDataById(@PathVariable Long id) {
        return myDataService.getById(id);
    }

    // 添加用户
    @PostMapping("/addData")
    public boolean addData(@RequestBody MyData myData) {
        return myDataService.save(myData);
    }

    @PostMapping("/test")
    public Object test(@RequestBody MyData myData){
        QueryWrapper<MyData> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(myData);
        return myDataService.getOne(queryWrapper);
    }

    @PostMapping("/test1")
    public Object test1(){
        return null;
    }
}
